C
C     ..................................................................
C
C        SUBROUTINE TRACE
C
C        PURPOSE
C           COMPUTE CUMULATIVE PERCENTAGE OF EIGENVALUES GREATER THAN
C           OR EQUAL TO A CONSTANT SPECIFIED BY THE USER.  THIS SUB-
C           ROUTINE NORMALLY OCCURS IN A SEQUENCE OF CALLS TO SUB-
C           ROUTINES CORRE, EIGEN, TRACE, LOAD, AND VARMX IN THE PER-
C           FORMANCE OF A FACTOR ANALYSIS.
C
C        USAGE
C           CALL TRACE (M,R,CON,K,D)
C
C        DESCRIPTION OF PARAMETERS
C           M     - NUMBER OF VARIABLES. M MUST BE > OR = TO 1
C           R     - INPUT MATRIX (SYMMETRIC AND STORED IN COMPRESSED
C                   FORM WITH ONLY UPPER TRIANGLE BY COLUMN IN CORE)
C                   CONTAINING EIGENVALUES IN DIAGONAL.  EIGENVALUES ARE
C                   ARRANGED IN DESCENDING ORDER.  THE ORDER OF MATRIX R
C                   IS M BY M.  ONLY M*(M+1)/2 ELEMENTS ARE IN STORAGE.
C                   (STORAGE MODE OF 1)
C           CON   - A CONSTANT USED TO DECIDE HOW MANY EIGENVALUES TO
C                   RETAIN.  CUMULATIVE PERCENTAGE OF EIGENVALUES
C                   WHICH ARE GREATER THAN OR EQUAL TO THIS VALUE IS
C                   CALCULATED.
C           K     - OUTPUT VARIABLE CONTAINING THE NUMBER OF EIGENVALUES
C                   GREATER THAN OR EQUAL TO CON.  (K IS THE NUMBER OF
C                   FACTORS.)
C           D     - OUTPUT VECTOR OF LENGTH M CONTAINING CUMULATIVE
C                   PERCENTAGE OF EIGENVALUES WHICH ARE GREATER THAN
C                   OR EQUAL TO CON.
C        REMARKS
C           NONE
C
C        SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED
C           NONE
C
C        METHOD
C           EACH EIGENVALUE GREATER THAN OR EQUAL TO CON IS DIVIDED BY M
C           AND THE RESULT IS ADDED TO THE PREVIOUS TOTAL TO OBTAIN
C           THE CUMULATIVE PERCENTAGE FOR EACH EIGENVALUE.
C
C     ..................................................................
C
      SUBROUTINE TRACE (M,R,CON,K,D)
      DIMENSION R(1),D(1)
C
C        ...............................................................
C
C        IF A DOUBLE PRECISION VERSION OF THIS ROUTINE IS DESIRED, THE
C        C IN COLUMN 1 SHOULD BE REMOVED FROM THE DOUBLE PRECISION
C        STATEMENT WHICH FOLLOWS.
C
C     DOUBLE PRECISION R,D
C
C        THE C MUST ALSO BE REMOVED FROM DOUBLE PRECISION STATEMENTS
C        APPEARING IN OTHER ROUTINES USED IN CONJUNCTION WITH THIS
C        ROUTINE.
C
C        ...............................................................
C
      FM=M
      L=0
      DO 100 I=1,M
      L=L+I
  100 D(I)=R(L)
      K=0
C
C     TEST WHETHER I-TH EIGENVALUE IS GREATER
C     THAN OR EQUAL TO THE CONSTANT
C
      DO 110 I=1,M
      IF(D(I)-CON) 120, 105, 105
  105 K=K+1
  110 D(I)=D(I)/FM
C
C     COMPUTE CUMULATIVE PERCENTAGE OF EIGENVALUES
C
  120 DO 130 I=2,K
  130 D(I)=D(I)+D(I-1)
      RETURN
      END
